package com.engine.salary.enums;


import java.util.Arrays;
import java.util.Objects;

/**
 * 进位规则
 * <p>Copyright: Copyright (c) 2022</p>
 * <p>Company: 泛微软件</p>
 *
 * @author qiantao
 * @version 1.0
 **/
public enum SalaryRoundingModeEnum implements BaseEnum<Integer> {

    RAW_DATA(1, "原始数据", 84504),
    ROUNDING(2, "四舍五入", 84505),
    ROUND_UP(3, "向上舍入", 84506),
    ROUND_DOWN(4, "向下舍入", 84507),
    CEILING(5, "见分进角", 84507),
    UP_EVEN(6, "向上求偶", 84507);

    private int value;

    private String defaultLabel;

    private int labelId;

    SalaryRoundingModeEnum(int value, String defaultLabel, int labelId) {
        this.value = value;
        this.defaultLabel = defaultLabel;
        this.labelId = labelId;
    }

    public static String getDefaultLabelByValue(Integer value) {
        if (value == null) {
            return "";
        }
        SalaryRoundingModeEnum[] enumAry = SalaryRoundingModeEnum.values();
        for (int i = 0; i < Arrays.asList(enumAry).size(); i++) {
            if (Integer.valueOf(enumAry[i].getValue()).equals(value)) {
                return enumAry[i].getDefaultLabel();
            }
        }
        return "";
    }

    @Override
    public Integer getValue() {
        return value;
    }

    @Override
    public String getDefaultLabel() {
        return defaultLabel;
    }

    @Override
    public Integer getLabelId() {
        return labelId;
    }

    public static SalaryRoundingModeEnum parseByValue(int value) {
        for (SalaryRoundingModeEnum modeEnum : SalaryRoundingModeEnum.values()) {
            if (Objects.equals(modeEnum.getValue(), value)) {
                return modeEnum;
            }
        }
        return ROUNDING;
    }

    public static SalaryRoundingModeEnum parseByDefaultLabel(String defaultLabel) {
        for (SalaryRoundingModeEnum modeEnum : SalaryRoundingModeEnum.values()) {
            if (Objects.equals(modeEnum.getDefaultLabel(), defaultLabel)) {
                return modeEnum;
            }
        }
        return ROUNDING;
    }
}
